(function($, doc) {
	$.init();
	var user = app.getState();
	function backup(e){
		var id = this.id;
		var btnArray = ['确定', '取消'];
			mui.prompt('请输入'+id+'钱包密码', '', '', btnArray, function(e) {
				if(e.index == 0) {
					//console.log(e.value);
					var pwd = e.value;
					if(pwd && pwd.length > 0) {
						var myWallet = ethscan.getWallet(id);
						if(myWallet.passwd != md5(pwd)) {
							$.toast("密码错误");
							return;
						}else{
							$.openWindow({'id' : 'showbackup', url : "showbackup.html",extras : {etype : id}});
						}
						/*
						var postdata = {
							user_id: user.user_id,
							address: id == 'eth' ? user.eth_address : user.btc_address,
							pwd : md5(e.value)
						};
						
						//console.log(JSON.stringify(postdata));
						$.post(apiurl + 'token/ckpwd', postdata, function(res) {
							//console.log(JSON.stringify(res));
							if(res.status > 0) {
								$.openWindow({'id' : 'showbackup', url : "showbackup.html",extras : {etype : id}});
							} else {
								$.toast("密码错误");
								return;
							}
						});*/
					}else{
						$.toast("密码不能为空！");
					}
				} else {
					
					//info.innerText = '你点了取消按钮';
				}
			}, 'div');
	}
	doc.getElementById("eth").addEventListener('tap',backup);
	doc.getElementById("btc").addEventListener('tap',backup);
	doc.getElementById("eos").addEventListener('tap',backup);
}(mui, document));